package com.sicheng.蓝桥.练习题;

import java.util.Scanner;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/1/17 23:38
 */
public class 数字游戏 {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int sum = scanner.nextInt();
        int sum1 = (n * (n * n - 1) / 2 - sum) / (n - 2);
        System.out.println(sum1);


        int j = 0, i;
        for (i = 1; i <= n; i++) {
            if ((j = sum1 - i) <= n && j != i) {
                break;
            }
        }

        System.out.print(i + " ");
        for (int k = 1; k <= n; k++) {
            if (k == i || k == j)
                continue;
            System.out.print(k + " ");
        }
        System.out.println(j);


    }
}
